import { $http } from '@/utils';
import { $ResponseCode } from '@/utils/const/env';
export const TechnicianService = {
    selection: (query: any) => {
        return new Promise((resolve, reject) => {
            $http.get('TechnicianService/selection', {
                data: query
            }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });

            })
        })
    },
    service: (query: any) => {
        return new Promise((resolve, reject) => {
            $http.get('TechnicianService/service', {
                data: query
            }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res.data);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    joinService: (service_id: any) => {
        return new Promise((resolve, reject) => {
            $http.post('TechnicianService/joinService', { data: { service_id } }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    updateState: (uts_id: any) => {
        return new Promise((resolve, reject) => {
            $http.post('TechnicianService/updateState', { data: { uts_id } }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    }
}